package com.dhq.myapp.util.dialog.custom

import android.content.Context
import android.graphics.drawable.AnimationDrawable
import android.view.View
import android.widget.ImageView
import android.widget.TextView
import com.dhq.myapp.R
import com.dhq.myapp.util.dialog.DialogBuilder
import com.lxj.xpopup.core.CenterPopupView

/**
 * DESC
 * Created by douhaoqiang on 2025/10/15.
 */
class DefaultLoadingPopup : CenterPopupView {
    var mBuilder: DialogBuilder? = null

    constructor(context: Context) : super(context)

    constructor(builder: DialogBuilder) : super(builder.context!!) {
        this.mBuilder = builder
    }

    override fun getImplLayoutId(): Int {
        return R.layout.dialog_wait_layout
        //        return 0;
    }

    override fun onCreate() {
        super.onCreate()

        val imgLoading = findViewById<ImageView?>(R.id.id_dialog_wait_imageview)
        imgLoading.setBackgroundResource(R.drawable.waitloding)
        val aniDraw = imgLoading.getBackground() as AnimationDrawable
        aniDraw.start()

        if (mBuilder!!.title != null) {
            (findViewById<View?>(R.id.id_dialog_wait_message) as TextView).setText(mBuilder!!.title)
        }
    }

    override fun onShow() {
        super.onShow()
    }

    //        @Override
    //        protected int getMaxHeight() {
    //            return 200;
    //        }
    //
    //返回0表示让宽度撑满window，或者你可以返回一个任意宽度
    override fun getMaxWidth(): Int {
        return 0
    }

    override fun getMinimumWidth(): Int {
        return getResources().getDimensionPixelOffset(R.dimen.dp750_400)
    }
}